define(function(require){
	var main =require('/static/main.js');
	var m = new main();
	function Cont(){
		this.Fun._init();
	}
	Cont.prototype.Fun = {
		_init:function(){
		    m.loadmenu('.cate-drainage',5);
		    this.getlist();
			this.bindEvent();
		},
		bindEvent:function(){
			
		},
		getlist:function(){
	        var param = {};
	        var sort = 0;
	        var table1 = $('#datatable').dataTable({
	        	'ordering':false,
	        	"serverSide": true,
	        	"searching":false,
	        	'bLengthChange': false,
	        	"scrollX": true,
	        	ajax: function (data, callback, settings) {
	                param.PageSize = data.length;
	                param.start = data.start;
	                param.PageNo = (data.start / data.length)+1;
	                param.ActGroupId = $_GET['id'];
	                $.ajax({
	                    type: "POST",
	                    url: "/drainage/group-join-list",
	                    cache: false,  
	                    data: param, 
	                    dataType: "json",
	                    success: function (result) {
                    	    var returnData = {};
                            returnData.draw = data.draw;
                            returnData.recordsTotal = result.total;
                            returnData.recordsFiltered = result.total;
                            returnData.data = result.data;
                            callback(returnData);
	                    }
	                });
	            },
				"aoColumns":[
					{
						"mDataProp": 'RecordId',
						render:function(data){
							sort ++;
                    		return sort;
                    	}
					}, 
					// {
			  //           "mDataProp": "RecordId",
			  //           "sClass": "option_btn",
			  //           "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
			  //               $(nTd).html('<div data-toggle="modal" data-target="#con-close-modal" style="display: inline-block;">\
     //                                              <a href="/drainage/turnplaterecord?id='+sData+'&parid='+$_GET['id']+'"  ><span class="btn_flow" style="margin-right:11px;">活动参与记录</span></a>\
     //                                            </div>');

			  //           }
			  //       },
					{"mDataProp": "MastRecordId"},
					{
                    	"mDataProp": 'IsMast',
                    	render:function(data){
                            return data ? '是' : '否';
                        }
                   	},
					{"mDataProp": "Nickname"},
					{
						"mDataProp": 'Photo',
						"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
							$(nTd).html('<img src="'+sData+'" onerror="this.src=\'/modules/img/default.jpg\'" style="width:50px;height:50px;">')
			            }
					},
                    {"mDataProp": "Phone"},
					{
                    	"mDataProp": 'JoinTime',
                        render:function(data){
                            if(data){
                                return m.formatTimeAll2(data)
                            }else{
                                return '';
                            }
                        }
                   	},
                    {
                        "mDataProp": 'EndTime',
                        render:function(data){
                            if(data){
                                return m.formatTimeAll2(data)
                            }else{
                                return '';
                            }
                        }
                    },
                    {
                        "mDataProp": 'CompleteTime',
                        render:function(data){
                            if(data){
                                return m.formatTimeAll2(data)
                            }else{
                                return '';
                            }
                        }
                    },
                    {
                        "mDataProp": 'GroupBuyStatus',
                        render:function(data){
                            if(data == 100){
                                return '已入团待完成'
                            }else if(data == 200){
                                return '已完成待发货'
                            }else if(data == 300){
                                return '已过期待退款'
                            }else if(data == 400){
                                return '已发货'
                            }else if(data == 500){
                                return '成功结束'
                            }else if(data == 600){
                                return '失败结束'
                            }else if(data == 610){
                            	return '退款失败'
                            }
                        }
                    },
                    
                    {
                        "mDataProp": 'OrderId',
                    },
                    {
                        "mDataProp": 'OrderType',
                        render:function(data){
                            return data == 100 ? '团购' : '直接购买';
                        }
                    },
                    {
                        "mDataProp": 'PayAmount',
                    },
                    // {
                    //     "mDataProp": 'PayAccount',
                    // },
                    {
                        "mDataProp": 'PaymentMethod',
                        render:function(data){
                            return data == 300 ? '微信' : '其他';
                        }
                    },
                    {
                        "mDataProp": 'PayNo',
                    },
                    {
                        "mDataProp": 'PayTime',
                        render:function(data){
                            if(data){
                                return m.formatTimeAll2(data)
                            }else{
                                return '';
                            }
                        }
                    },
                    {
                        "mDataProp": 'Consignee',
                    },
                    {
                        "mDataProp": 'ReceiverAdd',
                    },
                    {
                        "mDataProp": 'ExpressNo',
                    },
                    {
                        "mDataProp": 'ExpressCompany',
                    },
                    {
                        "mDataProp": 'Comment',
                    },
				],
	        }).api();
			// 点击搜索
	        $('#btnSearch').click(function(){
	        	param.StartTime = $('.StartTime').val()
	        	param.EndTime = $('.EndTime').val()
	        	param.Nickname = $('.Nickname').val()
	        	param.Phone = $('.Phone').val()
	        	sort = 0;
                table1.ajax.reload();
	        })
	        // 点击重置按钮
	        $('#btnRefresh').click(function(){
	        	$('.StartTime').val('');
	        	$('.EndTime').val('');
	        	$('.Nickname').val('');
	        	$('.Phone').val('');
                param.StartTime = '';
                param.EndTime = '';
                param.Nickname = '';
                param.Phone = '';
                var table = $('#datatable').DataTable();
                table.ajax.reload();
	        })
		},

	}
	var a = new Cont();

})